﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExpertSystem.Interfaces;

namespace ExpertSystem.Domains
{
    class FuzzyVariable : Variable
    {
        private int _number_of_values;
        private List<IVariable> _variables;
        private Dictionary< int,object> _valuesAndCF;
        private int _cf = 100;

        public FuzzyVariable(bool inputbyuser, string comment, string type, List<string> possiblevalues, bool isAsync) : base(inputbyuser, comment, type, possiblevalues, isAsync)
        {
            _variables =  new List<IVariable>();
            _valuesAndCF = new Dictionary<int, object>();
        }

        public int CurreFactor
        {
            get { return _cf; }
            set { _cf = value; }
        }
        public override object Value
        {
            get
            {
                if(_valuesAndCF.Count > 0)
                    return _valuesAndCF[_valuesAndCF.Max(kv => kv.Key)];
                else
                {
                    return null;
                }
            }
            set
            {
                _valued = true;
                _valuesAndCF.Add(_cf, value);
                _cf = _valuesAndCF.Keys.Max();
            }
        }

        public override bool IsFuzzy
        {
            get
            {
                return true;
            }
        }
        
    }
}
